package leetcode_acm.array;

import com.sun.org.apache.bcel.internal.generic.IFEQ;

/**
 * 功能描述
 *
 * @author: 张庭杰
 * @date: 2023年03月21日 17:23
 */
public class SmallerNumbersThanCurrent {
    public int[] smallerNumbersThanCurrent(int[] nums) {
        if (nums == null || nums.length == 0) {
            return nums;
        }
        int[] freq = new int[101];
        for (int num : nums) {
            freq[num]++;
        }
        for (int i = 1; i < 101; i++) {
            freq[i] = freq[i-1]+freq[i];
        }
        int[] ans = new int[nums.length];
        for (int i = 1; i < ans.length; i++) {
            ans[i] = freq[nums[i]-1];
        }
        return ans;
    }


}
